package edu.univercidade.tcc.server.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;

import ca.digitalface.jasperoo.RooJasperoo;
import edu.univercidade.tcc.shared.model.ProjectStatus;

@RooJavaBean
@RooToString
@RooJasperoo
@RooEntity(finders = { "findProjectsById" })
public class Project {

    @Column(name = "created_on", updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Date createdOn;

    @NotNull
    @Size(max = 4096)
    private String description;

    @NotNull @NotBlank
    @Size(max = 255)
    private String name;

    @NotNull
    @Enumerated(EnumType.STRING)
    private ProjectStatus status;

    @ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
    private Set<Tracker> trackers = new HashSet<Tracker>();
    
	@Override
	public String toString() {
		return name;
	}
}
